package com.cjh.mybatis09.bulider;

import com.cjh.mybatis09.mapping.BoundSql;
import com.cjh.mybatis09.mapping.ParameterMapping;
import com.cjh.mybatis09.mapping.SqlSource;
import com.cjh.mybatis09.session.Configuration;

import java.util.List;

/**
 * @Descripton 静态sql源码
 * @Author cjh
 * @Date 2023/6/12 14:40
 */
public class StaticSqlSource implements SqlSource {
    private String sql;
    private List<ParameterMapping> parameterMappings;
    private Configuration configuration;


    public StaticSqlSource(String sql, Configuration configuration) {
        this(sql,null,configuration);
    }

    public StaticSqlSource(String sql, List<ParameterMapping> parameterMappings, Configuration configuration) {
        this.sql = sql;
        this.parameterMappings = parameterMappings;
        this.configuration = configuration;
    }

    @Override
    public BoundSql getBoundSql(Object parameterObject) {
        return new BoundSql(configuration,sql,parameterMappings,parameterObject);
    }
}
